package com.ruoyi.common.verify.validator;

import cn.hutool.core.util.IdcardUtil;
import com.ruoyi.common.verify.BaseValidator;
import com.ruoyi.common.verify.annotation.IdCard;

/**
 * 自定义身份证号校验注解实现
 *
 * @author ruoyi
 */
public class IdCardValidator extends BaseValidator<IdCard, String> {

    public boolean valid(String value, IdCard phone) {
        if (phone.isNotNull() && !isNotNull(value)) {
            return false;
        }
        return IdcardUtil.isValidCard(value);
    }
}
